<template>
  <div>
    <header class="head">连接线配置</header>
    <el-form label-width="100px">
      <el-form-item label="默认分支：">
        <el-checkbox
          v-model="formData.isDefault"
          :disabled="isView"
          @change="handleDefault"
        ></el-checkbox>
      </el-form-item>
      <el-form-item label="分支条件：">
        <el-input
          v-model="formData.rule"
          :disabled="isView"
          type="textarea"
          placeholder="请输入分支条件"
          style="width: 100%"
          @change="handleRule"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import { mapState } from "vuex";
import {serviceStore} from '@slc/store/service';
import {flowServiceStore} from '@slc/store/flowService';
import {mapActions, mapState} from 'pinia';


export default {
  name: "custom-line",
  computed: {
    ...mapState(flowServiceStore, ["moreNodeInfo", "currentNodeId", "selectNode"]),
    ...mapState(serviceStore, ["dialogStatus", "dialogVersionStatus"]),
    formData: {
      get() {
        return this.moreNodeInfo[this.currentNodeId];
      },
      set(val) {
        this.setMoreNodeInfo({
          ...this.moreNodeInfo,
          [this.currentNodeId]: val,
        });
      },
    },
    isView() {
      return (
        this.dialogStatus === "view" || this.dialogVersionStatus === "view"
      );
    },
  },
  methods: {
      ...mapActions(flowServiceStore, ["setMoreNodeInfo"]),
      handleDefault(val) {
      if (val) {
        this.selectNode.setLabels("默认");
      } else {
        this.selectNode.setLabels("");
      }
    },
    handleRule() {
      this.selectNode.setLabels(this.formData.rule);
    },
  },
};
</script>

<style lang="scss" scoped>
.head {
  height: 40px;
  text-align: center;
  line-height: 40px;
  color: #333;
  font-weight: bold;
  font-size: 14px;
  background-color: #ccc;
  margin-bottom: 16px;
}
.el-form-item {
  margin-bottom: 0px;
}
</style>
